import { Component } from "react";
import ThemeContext from "./context";

export default class Votefooter extends Component{
    render(){
        //Consumer 消费者
        //后代组件，通过 ThemeContext.Consumer来接收参数，必须是函数
        return <ThemeContext.Consumer>
            {(context)=>{//祖先组件的参数在：context
                let {add}=context;
                return  <div>
                        <button onClick={()=>{
                            add("sup")
                        }}>支持</button>
                        <button onClick={add.bind(null,"opp")}>反对</button>
                    </div>
            }}
        </ThemeContext.Consumer>
    }
}